package com.zdd.threelayoutproxy;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @version 1.0
 * @Author: carl
 * @Description:
 * @Date: Create in 18:59 2020/10/7 0007
 */
public class Main {

    // 静态代理调用
//    public static void main(String[] args){
//        try{
//            Order order = new Order();
//            SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
//            Date date = sdf.parse("2017/02/01");
//            order.setCreateTime(date.getTime());
//            IOrderService orderService = new OrderServiceStaticProxy(new OrderService());
//            orderService.createOrder(order);
//        }catch (Exception e){
//            e.printStackTrace();
//        }
//    }

    // 动态代理调用
    public static void main(String[] args){
        try{
            Order order = new Order();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
            Date date = sdf.parse("2019/02/01");
            order.setCreateTime(date.getTime());

            IOrderService orderService = (IOrderService) new OrderServiceDynamicProxy().getInstance(new OrderService());
            orderService.createOrder(order);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
